//
//  singleResumeCells.swift
//  万才信息App
//
//  Created by 鹏速科技 on 16/8/2.
//  Copyright © 2016年 万才信息. All rights reserved.
//

import UIKit


//只有一个标题的headercell
class basicHeaderCell:UITableViewCell{
    
    @IBOutlet weak var tvTitle: UILabel!
    
    func setTitle(title:String){
        tvTitle.text=title
    }
    
}

//有一个添加按钮的headercell
class addHeaderCell:UITableViewCell{
    
    @IBOutlet weak var tvTitle: UILabel!
    var segueIden:String = ""
    var controller:UITableViewController=UITableViewController()
    
    @IBAction func pressAdd(sender: AnyObject) {
        controller.performSegueWithIdentifier(segueIden, sender: "测试传值")
    }
    
    
    func setTitle(title:String){
        tvTitle.text=title
    }
    
    func setSegue(segueIden:String,controller:UITableViewController){
        self.segueIden=segueIden
        self.controller=controller
    }

}

//是否保密的cell
class isPrivacyCell:UITableViewCell{
    
    @IBOutlet weak var privacySwitch: UISwitch!
    
    var isOpen:Bool = true
    var resumeID:String = ""
    var controller:UITableViewController = UITableViewController()
    
    func setOpen(open:Bool,resumeId:String,controller:UITableViewController){
        isOpen=open
        privacySwitch.on=isOpen
        resumeID=resumeId
        self.controller=controller
    }
    
    @IBAction func changePrivacy(sender: UISwitch, forEvent event: UIEvent) {
        isOpen = sender.on
        var privacy = 2
        if isOpen{
            privacy = 1
        }
        
        resumeManager.UpdateResumePrivacy(self.resumeID, privacy: privacy, successCallback: { (msg) in
            print("更改privacy成功")
            }) { (error) in
                warningAlertUtil(title: "错误", msg: error).show(self.controller)
        }
    }
    
}

//autoHeightLabel
class autoHeightLabelCell:UITableViewCell{
    
    @IBOutlet weak var tvInfo: UILabel!
    
    var controller:UITableViewController = UITableViewController()
    var segueInden:String = "toUpdBasicInfo"
    
    @IBAction func pressEdit(sender: AnyObject) {
        controller.performSegueWithIdentifier(segueInden, sender: nil)
    }
    
    func setInfo(info:String){
        print("设置自适应高度cell，info=")
        print(info)
        tvInfo.text = info
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
}

//TODO 语言能力cell
class languageCell:UITableViewCell{
    
    var language:languageAbility=languageAbility()
    var controller:UITableViewController = UITableViewController()
    
    @IBAction func pressEdit(sender: AnyObject) {
        controller.performSegueWithIdentifier("toUpdLan", sender: language)
    }
    
    @IBOutlet weak var tvLanguageName: UILabel!
    @IBOutlet weak var tvMaster: UILabel!
    @IBOutlet weak var tvOtherMaster: UILabel!
    
    func setLanguage(language:languageAbility){
        self.language=language
        
        tvLanguageName.text = language.lantype
        tvMaster.text = "掌握程度:" + language.lanmaster
        tvOtherMaster.text = "读写能力:"+language.lanrwability + "     听说能力:" + language.lanlsability
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
}

//TODO 工作经历cell
class workCell:UITableViewCell{
    
    var work:workExperience=workExperience()
    var controller:UITableViewController = UITableViewController()
    
    @IBOutlet weak var tvCompanyName: UILabel!
    @IBOutlet weak var tvCompanyNature: UILabel!
    @IBOutlet weak var tvJobName: UILabel!
    @IBOutlet weak var tvJobDescription: UILabel!
    @IBOutlet weak var tvTime: UILabel!
    
    
    @IBAction func pressEdit(sender: AnyObject) {
        controller.performSegueWithIdentifier("toUpdWork", sender: work)
    }
    
    func setWork(work:workExperience){
        self.work=work
        tvCompanyName.text = work.CompanyName
//        let companyNature=enumUtil.getStringByKey(Int(work.CompanyNature)!, dict: enumUtil.RESUME_WORKNATURE)
        let companySize=enumUtil.getStringByKey(Int(work.CompanySize)!, dict: enumUtil.COMPANY_SCALE)
        tvCompanyNature.text="（"+companySize+"）"
        tvJobName.text=work.IndustryName + "、"+work.SubFunction
        tvJobDescription.text="工作描述："+work.Responsiblity
        tvTime.text =  DateUtil.transferJSONDateToNormalDate(work.StartDate)  + " - "+DateUtil.transferJSONDateToNormalDate(work.EndDate)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
}

//TODO 培训经历cell
class trainCell:UITableViewCell{
    
    var train:trainExperience=trainExperience()
    var controller:UITableViewController = UITableViewController()
    
    @IBOutlet weak var tvOrgName: UILabel!
    @IBOutlet weak var tvTrainName: UILabel!
    @IBOutlet weak var tvTrainDescription: UILabel!
    @IBOutlet weak var tvTime: UILabel!
    
    @IBAction func pressEdit(sender: AnyObject) {
        controller.performSegueWithIdentifier("toUpdTrain", sender: train)
    }
    
    
    func setTrain(train:trainExperience){
        self.train=train
        
        tvOrgName.text=train.TrainedOrg
        tvTrainName.text=train.TrainedName
        tvTrainDescription.text="培训描述："+train.Description
        tvTime.text = DateUtil.transferJSONDateToNormalDate(train.StartDate) + " - "+DateUtil.transferJSONDateToNormalDate(train.EndDate)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
}

//TODO 教育经历cell
class eduCell:UITableViewCell{
    
    var edu:listEduExperience=listEduExperience()
    var controller:UITableViewController = UITableViewController()
    
    @IBOutlet weak var tvSchoolName: UILabel!
    @IBOutlet weak var tvMajor: UILabel!
    @IBOutlet weak var tvTime: UILabel!
    
    @IBAction func pressEdit(sender: AnyObject) {
        controller.performSegueWithIdentifier("toUpdEdu", sender: edu)

    }
    func setEdu(edu:listEduExperience){
        self.edu=edu
        
        tvSchoolName.text=edu.SchoolName
        
        tvMajor.text=edu.ChineseName+" "+edu.Major
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }
}